#pragma once

#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "RoomLightComponent.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnLightStateChanged, bool, bLightOn, bool, bIsInit);

UCLASS(Blueprintable, Abstract, ClassGroup =(RoomLight))
class PHOBIA_API URoomLightComponent : public UActorComponent
{
	GENERATED_BODY()

protected:
	virtual void BeginPlay() override;
	virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;

public:
	// 开灯
	UFUNCTION(BlueprintCallable)
	void TurnOnLight(bool bIsInit = false);

	// 关灯
	UFUNCTION(BlueprintCallable)
	void TurnOffLight(bool bIsInit = false);

protected:
	// 开灯逻辑
	UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName = "Light On"))
	void ReceiveLightOn(bool bIsInit);
	virtual void LightOn(bool bIsInit);

	// 关灯逻辑
	UFUNCTION(BlueprintImplementableEvent, meta=(DisplayName = "Light Off"))
	void ReceiveLightOff(bool bIsInit);
	virtual void LightOff(bool bIsInit);

public:
	UPROPERTY(BlueprintAssignable)
	FOnLightStateChanged OnLightStateChanged;

private:
	UPROPERTY(Transient)
	TArray<TObjectPtr<ULightComponentBase>> LightComponents;
};
